import javax.xml.crypto.dsig.spec.XSLTTransformParameterSpec;
import java.util.*;
public class Day6 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9,10};
        //maxProduct(arr);
        System.out.println("fawfasf");
    }


    //918.环形子数组的最大和
    public int maxSubarraySumCircular(int[] nums) {
        int n = nums.length;
        int[] f = new int[n];//最大子数组和
        int[] g = new int[n];//最小子数组和
        f[0]=g[0]=nums[0];
        int x=f[0],y=g[0],sum=nums[0];
        for(int i=1;i<n;i++) {
            sum+=nums[i];//求数组总和
            f[i]=Math.max(nums[i],f[i-1]+nums[i]);
            g[i]=Math.min(nums[i],g[i-1]+nums[i]);
            x=Math.max(x,f[i]);
            y=Math.min(y,g[i]);
        }
        if(sum==y) return x;
        return x>(sum-y)?x:sum-y;
    }
    //152.乘积最大子数组
    public int maxProduct(int[] nums) {
        int n = nums.length;
        int[] f = new int[n];//最大子数组的乘积
        int[] g = new int[n];//最小子数组的乘积
        f[0]=g[0]=nums[0];
        int ret=f[0];
        for(int i=1;i<n;i++) {
            if(nums[i] < 0) {
                f[i]=Math.max(nums[i],g[i-1]*nums[i]);
                g[i]=Math.min(nums[i],nums[i]*f[i-1]);
            }else {
                f[i]=Math.max(nums[i],nums[i]*f[i-1]);
                g[i]=Math.min(nums[i],nums[i]*g[i-1]);
            }
            ret=Math.max(ret,f[i]);
        }
        return ret;
    }
    //1.两数之和
    public int[] twoSum(int[] nums, int target) {
        int[] ret = {0,0};
        int n = nums.length;
        Map<Integer,Integer> map = new HashMap<>();
        for(int i=0;i<n;i++) {
            int tmp = target - nums[i];
            if(map.getOrDefault(tmp,-1)!=-1) {
                ret[0]=i;
                ret[1]=map.get(tmp);
                return ret;
            }
            map.put(nums[i],i);
        }
        return ret;
    }
}
